// components/songs/songs.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        song: {
            type: Object
        }
    },
    data: {
        _count: 0
    },
    observers: {
        "song.playCount": function (count) {
            this.setData({
                _count: this.formatPlayCount(count, 2)
            })
        }
    },
    methods: {
        goToDetails() {
            wx.navigateTo({
                url: '/pages/details/details?playListId=' + this.properties.song.id,
            })
        },
        formatPlayCount(count, point = 2) {
            let value = count.toString().split(".")[0];
            if (value.length < 5) {
                return value;
            } else if (value.length >= 5 && value.length <= 8) {
                let dicimal = value.substring(value.length - 4, value.length - 4 + point);
                return parseInt(value / 10000) + "." + dicimal + "万"
            } else if (value.length > 8) {
                let dicimal = value.substring(value.length - 8, value.length - 8 + point);
                return parseInt(value / 100000000) + "." + dicimal + "亿"
            }
        }
    }
})